Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
¿Cómo puedo solicitar el formato de fecha "yyyy-mm-dd" sin analizar y reformatear?

Estoy usando PostGreSql que contiene la columna de fecha en una de las tablas 2021-12-03T00:00:00.000Z . Desarrollé API usando nodejs para obtener los datos de las tablas.

A continuación se muestra la función que escribí para formatear la fecha y pasar a la clase. Esto funciona perfectamente bien y 2021-12-03 como salida

 formatDate(date) { var d = new Date(date), month = '' + (d.getMonth() + 1), day = '' + (d.getDate() + 1), year = d.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; return [year, month, day].join('-'); } async getData(date){ return { DataLine: await this._dateLine.getData1(d) } }

aplicación.js

 class Data extends Model { constructor(conn, schema) { super(conn, schema, "data", { Date: date(true), number: integer(true), ...many other column }, true); } async getData1(date) { return (await this._permanent.findAll({ where: { td:date } })).map((term) => ({ td: term.transDate, number: term.number, })); } }

¿Hay alguna manera de require them in the "yyyy-mm-dd" format to begin with y no analizar / reformatear como lo hice anteriormente, ya que ya estoy obteniendo la fecha en formato yyyy-mm-dd , mi función rehace eso?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Una de las formas más fáciles de obtener aaaa-mm-dd es new Date().toISOString().split('T')[0]

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!